package swing;

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

public class FlowLayoutDemo4 extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					FlowLayoutDemo4 frame = new FlowLayoutDemo4();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public FlowLayoutDemo4() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		CardLayout card=new CardLayout();
		contentPane.setLayout(card);
		contentPane.add(new JLabel("标签-A",JLabel.CENTER),"first"); 
		contentPane.add(new JLabel("标签-B",JLabel.CENTER),"second");
		contentPane.add(new JLabel("标签-C",JLabel.CENTER),"third");
		contentPane.add(new JLabel("标签-D",JLabel.CENTER),"fouth");
		contentPane.add(new JLabel("标签-E",JLabel.CENTER),"fifth");
		pack();
		setVisible(true);
		card.show(contentPane, "third");
		for (int i = 0; i < 5; i++) {
			try {
				Thread.sleep(300);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				card.next(contentPane);
			}
			
		}
	}

}
